﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Snowy.Data.PostgreSQL.Migrations
{
    public partial class InitializeSchema : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "sys_app",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键id"),
                    name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "应用名称"),
                    code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "编码"),
                    active = table.Column<string>(type: "character varying(1)", maxLength: 1, nullable: true, comment: "是否默认激活（Y-是，N-否）"),
                    status = table.Column<short>(type: "smallint", nullable: false, comment: "状态（字典 0正常 1停用 2删除）"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "修改时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "修改人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_app", x => x.id);
                },
                comment: "系统应用表");

            migrationBuilder.CreateTable(
                name: "sys_code_generate",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    author_name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "作者姓名"),
                    class_name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "类名"),
                    table_prefix = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "是否移除表前缀"),
                    generate_type = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "生成位置类型"),
                    table_name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "数据库表名"),
                    package_name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "包名称"),
                    bus_name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "业务名"),
                    table_comment = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "功能名"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "更新人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "更新时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_code_generate", x => x.id);
                },
                comment: "代码生成基础配置");

            migrationBuilder.CreateTable(
                name: "sys_code_generate_config",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    code_gen_id = table.Column<long>(type: "bigint", nullable: true, comment: "代码生成主表ID"),
                    column_name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "数据库字段名"),
                    java_name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "java类字段名"),
                    data_type = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "物理类型"),
                    column_comment = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "字段描述"),
                    java_type = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "java类型"),
                    effect_type = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "作用类型（字典）"),
                    dict_type_code = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "字典code"),
                    whether_table = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "列表展示"),
                    whether_add_update = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "增改"),
                    whether_retract = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "列表是否缩进（字典）"),
                    whether_required = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "是否必填（字典）"),
                    query_whether = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "是否是查询条件"),
                    query_type = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "查询方式"),
                    column_key = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "主键"),
                    column_key_name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "主外键名称"),
                    whether_common = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "是否是通用字段"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "修改时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "修改人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_code_generate_config", x => x.id);
                },
                comment: "代码生成详细配置");

            migrationBuilder.CreateTable(
                name: "sys_config",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "名称"),
                    code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "编码"),
                    value = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "值"),
                    sys_flag = table.Column<char>(type: "character(1)", maxLength: 1, nullable: false, comment: "是否是系统参数（Y-是，N-否）"),
                    remark = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "备注"),
                    status = table.Column<short>(type: "smallint", nullable: false, comment: "状态（字典 0正常 1停用 2删除）"),
                    group_code = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "常量所属分类的编码，来自于“常量的分类”字典"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "更新时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "更新人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_config", x => x.id);
                },
                comment: "系统参数配置表");

            migrationBuilder.CreateTable(
                name: "sys_dict_data",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    type_id = table.Column<long>(type: "bigint", nullable: false, comment: "字典类型id"),
                    value = table.Column<string>(type: "text", nullable: false, comment: "值"),
                    code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "编码"),
                    sort = table.Column<int>(type: "integer", nullable: false, comment: "排序"),
                    remark = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "备注"),
                    status = table.Column<short>(type: "smallint", nullable: false, comment: "状态（字典 0正常 1停用 2删除）"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "更新时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "更新人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_dict_data", x => x.id);
                },
                comment: "系统字典值表");

            migrationBuilder.CreateTable(
                name: "sys_dict_type",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "名称"),
                    code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "编码"),
                    sort = table.Column<int>(type: "integer", nullable: false, comment: "排序"),
                    remark = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "备注"),
                    status = table.Column<short>(type: "smallint", nullable: false, comment: "状态（字典 0正常 1停用 2删除）"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "更新时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "更新人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_dict_type", x => x.id);
                },
                comment: "系统字典类型表");

            migrationBuilder.CreateTable(
                name: "sys_emp",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    job_num = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true, comment: "工号"),
                    org_id = table.Column<long>(type: "bigint", nullable: false, comment: "所属机构id"),
                    org_name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "所属机构名称")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_emp", x => x.id);
                },
                comment: "员工表");

            migrationBuilder.CreateTable(
                name: "sys_emp_ext_org_pos",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    emp_id = table.Column<long>(type: "bigint", nullable: false, comment: "员工id"),
                    org_id = table.Column<long>(type: "bigint", nullable: false, comment: "机构id"),
                    pos_id = table.Column<long>(type: "bigint", nullable: false, comment: "岗位id")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_emp_ext_org_pos", x => x.id);
                },
                comment: "员工附属机构岗位表");

            migrationBuilder.CreateTable(
                name: "sys_emp_pos",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    emp_id = table.Column<long>(type: "bigint", nullable: false, comment: "员工id"),
                    pos_id = table.Column<long>(type: "bigint", nullable: false, comment: "职位id")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_emp_pos", x => x.id);
                },
                comment: "员工职位关联表");

            migrationBuilder.CreateTable(
                name: "sys_file_info",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键id"),
                    file_location = table.Column<short>(type: "smallint", nullable: false, comment: "文件存储位置（1:阿里云，2:腾讯云，3:minio，4:本地）"),
                    file_bucket = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true, comment: "文件仓库"),
                    file_origin_name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "文件名称（上传时候的文件名）"),
                    file_suffix = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "文件后缀"),
                    file_size_kb = table.Column<long>(type: "bigint", nullable: true, comment: "文件大小kb"),
                    file_size_info = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true, comment: "文件大小信息，计算后的"),
                    file_object_name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "存储到bucket的名称（文件唯一标识id）"),
                    file_path = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true, comment: "存储路径"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建用户"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "修改时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "修改用户")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_file_info", x => x.id);
                },
                comment: "文件信息表");

            migrationBuilder.CreateTable(
                name: "sys_menu",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    pid = table.Column<long>(type: "bigint", nullable: false, comment: "父id"),
                    pids = table.Column<string>(type: "text", nullable: false, comment: "父ids"),
                    name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "名称"),
                    code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "编码"),
                    type = table.Column<short>(type: "smallint", nullable: false, defaultValueSql: "1", comment: "菜单类型（字典 0目录 1菜单 2按钮）"),
                    icon = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "图标"),
                    router = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "路由地址"),
                    component = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "组件地址"),
                    permission = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "权限标识"),
                    application = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "应用分类（应用编码）"),
                    open_type = table.Column<short>(type: "smallint", nullable: false, comment: "打开方式（字典 0无 1组件 2内链 3外链）"),
                    visible = table.Column<char>(type: "character(1)", maxLength: 1, nullable: false, comment: "是否可见（Y-是，N-否）"),
                    link = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "链接地址"),
                    redirect = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "重定向地址"),
                    weight = table.Column<short>(type: "smallint", nullable: true, comment: "权重（字典 1系统权重 2业务权重）"),
                    sort = table.Column<int>(type: "integer", nullable: false, comment: "排序"),
                    remark = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "备注"),
                    status = table.Column<short>(type: "smallint", nullable: false, comment: "状态（字典 0正常 1停用 2删除）"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "修改时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "修改人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_menu", x => x.id);
                },
                comment: "系统菜单表");

            migrationBuilder.CreateTable(
                name: "sys_notice",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    title = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true, comment: "标题"),
                    content = table.Column<string>(type: "text", nullable: true, comment: "内容"),
                    type = table.Column<short>(type: "smallint", nullable: false, comment: "类型（字典 1通知 2公告）"),
                    public_user_id = table.Column<long>(type: "bigint", nullable: false, comment: "发布人id"),
                    public_user_name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "发布人姓名"),
                    public_org_id = table.Column<long>(type: "bigint", nullable: true, comment: "发布机构id"),
                    public_org_name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "发布机构名称"),
                    public_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "发布时间"),
                    cancel_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "撤回时间"),
                    status = table.Column<short>(type: "smallint", nullable: false, comment: "状态（字典 0草稿 1发布 2撤回 3删除）"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "修改时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "修改人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_notice", x => x.id);
                },
                comment: "通知表");

            migrationBuilder.CreateTable(
                name: "sys_notice_user",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    notice_id = table.Column<long>(type: "bigint", nullable: false, comment: "通知公告id"),
                    user_id = table.Column<long>(type: "bigint", nullable: false, comment: "用户id"),
                    status = table.Column<short>(type: "smallint", nullable: false, comment: "状态（字典 0未读 1已读）"),
                    read_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "阅读时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_notice_user", x => x.id);
                },
                comment: "系统用户数据范围表");

            migrationBuilder.CreateTable(
                name: "sys_oauth_user",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    uuid = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "第三方平台的用户唯一id"),
                    access_token = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "用户授权的token"),
                    nick_name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "昵称"),
                    avatar = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true, comment: "头像"),
                    blog = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "用户网址"),
                    company = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "所在公司"),
                    location = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "位置"),
                    email = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "邮箱"),
                    gender = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "性别"),
                    source = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "用户来源"),
                    remark = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "用户备注（各平台中的用户个人介绍）"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建用户"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "更新时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "更新用户")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_oauth_user", x => x.id);
                },
                comment: "第三方认证用户信息表");

            migrationBuilder.CreateTable(
                name: "sys_op_log",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "名称"),
                    op_type = table.Column<short>(type: "smallint", nullable: true, comment: "操作类型"),
                    success = table.Column<char>(type: "character(1)", maxLength: 1, nullable: true, comment: "是否执行成功（Y-是，N-否）"),
                    message = table.Column<string>(type: "text", nullable: true, comment: "具体消息"),
                    ip = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "ip"),
                    location = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "地址"),
                    browser = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "浏览器"),
                    os = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "操作系统"),
                    url = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true, comment: "请求地址"),
                    class_name = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true, comment: "类名称"),
                    method_name = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true, comment: "方法名称"),
                    req_method = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "请求方式（GET POST PUT DELETE)"),
                    param = table.Column<string>(type: "text", nullable: true, comment: "请求参数"),
                    result = table.Column<string>(type: "text", nullable: true, comment: "返回结果"),
                    op_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "操作时间"),
                    account = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "操作账号")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_op_log", x => x.id);
                },
                comment: "系统操作日志表");

            migrationBuilder.CreateTable(
                name: "sys_org",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    pid = table.Column<long>(type: "bigint", nullable: false, comment: "父id"),
                    pids = table.Column<string>(type: "text", nullable: false, comment: "父ids"),
                    name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "名称"),
                    code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "编码"),
                    sort = table.Column<int>(type: "integer", nullable: false, comment: "排序"),
                    remark = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "描述"),
                    status = table.Column<short>(type: "smallint", nullable: false, comment: "状态（字典 0正常 1停用 2删除）"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "更新时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "更新人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_org", x => x.id);
                },
                comment: "系统组织机构表");

            migrationBuilder.CreateTable(
                name: "sys_pos",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "名称"),
                    code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "编码"),
                    sort = table.Column<int>(type: "integer", nullable: false, comment: "排序"),
                    remark = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "备注"),
                    status = table.Column<short>(type: "smallint", nullable: false, comment: "状态（字典 0正常 1停用 2删除）"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "更新时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "更新人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_pos", x => x.id);
                },
                comment: "系统职位表");

            migrationBuilder.CreateTable(
                name: "sys_role",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键id"),
                    name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "名称"),
                    code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "编码"),
                    sort = table.Column<int>(type: "integer", nullable: false, comment: "序号"),
                    data_scope_type = table.Column<short>(type: "smallint", nullable: false, defaultValueSql: "1", comment: "数据范围类型（字典 1全部数据 2本部门及以下数据 3本部门数据 4仅本人数据 5自定义数据）"),
                    remark = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "备注"),
                    status = table.Column<short>(type: "smallint", nullable: false, comment: "状态（字典 0正常 1停用 2删除）"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "更新时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "更新人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_role", x => x.id);
                },
                comment: "系统角色表");

            migrationBuilder.CreateTable(
                name: "sys_role_data_scope",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    role_id = table.Column<long>(type: "bigint", nullable: false, comment: "角色id"),
                    org_id = table.Column<long>(type: "bigint", nullable: false, comment: "机构id")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_role_data_scope", x => x.id);
                },
                comment: "系统角色数据范围表");

            migrationBuilder.CreateTable(
                name: "sys_role_menu",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    role_id = table.Column<long>(type: "bigint", nullable: false, comment: "角色id"),
                    menu_id = table.Column<long>(type: "bigint", nullable: false, comment: "菜单id")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_role_menu", x => x.id);
                },
                comment: "系统角色菜单表");

            migrationBuilder.CreateTable(
                name: "sys_sms",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    phone_numbers = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false, comment: "手机号"),
                    validate_code = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "短信验证码"),
                    template_code = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "短信模板ID"),
                    biz_id = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "回执id，可根据该id查询具体的发送状态"),
                    status = table.Column<short>(type: "smallint", nullable: false, comment: "发送状态（字典 0 未发送，1 发送成功，2 发送失败，3 失效）"),
                    source = table.Column<short>(type: "smallint", nullable: false, comment: "来源（字典 1 app， 2 pc， 3 其他）"),
                    invalid_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "失效时间"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "更新时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "更新人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_sms", x => x.id);
                },
                comment: "短信信息发送表");

            migrationBuilder.CreateTable(
                name: "sys_timers",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "定时器id"),
                    timer_name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "任务名称"),
                    action_class = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "执行任务的class的类名（实现了TimerTaskRunner接口的类的全称）"),
                    cron = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "定时任务表达式"),
                    job_status = table.Column<short>(type: "smallint", nullable: true, comment: "状态（字典 1运行  2停止）"),
                    remark = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true, comment: "备注信息"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "更新时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "更新人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_timers", x => x.id);
                },
                comment: "定时任务");

            migrationBuilder.CreateTable(
                name: "sys_user",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    account = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "账号"),
                    password = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "密码"),
                    nick_name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "昵称"),
                    name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "姓名"),
                    avatar = table.Column<long>(type: "bigint", nullable: true, comment: "头像"),
                    birthday = table.Column<DateTime>(type: "date", nullable: true, comment: "生日"),
                    sex = table.Column<short>(type: "smallint", nullable: false, comment: "性别(字典 1男 2女 3未知)"),
                    email = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "邮箱"),
                    phone = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "手机"),
                    tel = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "电话"),
                    last_login_ip = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true, comment: "最后登陆IP"),
                    last_login_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "最后登陆时间"),
                    admin_type = table.Column<short>(type: "smallint", nullable: false, comment: "管理员类型（0超级管理员 1非管理员）"),
                    status = table.Column<short>(type: "smallint", nullable: false, comment: "状态（字典 0正常 1冻结 2删除）"),
                    create_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "创建时间"),
                    create_user = table.Column<long>(type: "bigint", nullable: true, comment: "创建人"),
                    update_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "更新时间"),
                    update_user = table.Column<long>(type: "bigint", nullable: true, comment: "更新人")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_user", x => x.id);
                },
                comment: "系统用户表");

            migrationBuilder.CreateTable(
                name: "sys_user_data_scope",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    user_id = table.Column<long>(type: "bigint", nullable: false, comment: "用户id"),
                    org_id = table.Column<long>(type: "bigint", nullable: false, comment: "机构id")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_user_data_scope", x => x.id);
                },
                comment: "系统用户数据范围表");

            migrationBuilder.CreateTable(
                name: "sys_user_role",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    user_id = table.Column<long>(type: "bigint", nullable: false, comment: "用户id"),
                    role_id = table.Column<long>(type: "bigint", nullable: false, comment: "角色id")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_user_role", x => x.id);
                },
                comment: "系统用户角色表");

            migrationBuilder.CreateTable(
                name: "sys_vis_log",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", nullable: false, comment: "主键"),
                    name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "名称"),
                    success = table.Column<char>(type: "character(1)", maxLength: 1, nullable: true, comment: "是否执行成功（Y-是，N-否）"),
                    message = table.Column<string>(type: "text", nullable: true, comment: "具体消息"),
                    ip = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "ip"),
                    location = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "地址"),
                    browser = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "浏览器"),
                    os = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, comment: "操作系统"),
                    vis_type = table.Column<short>(type: "smallint", nullable: false, comment: "操作类型（字典 1登入 2登出）"),
                    vis_time = table.Column<DateTime>(type: "timestamp(6) without time zone", precision: 6, nullable: true, comment: "访问时间"),
                    account = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "访问账号")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_vis_log", x => x.id);
                },
                comment: "系统访问日志表");

            migrationBuilder.CreateIndex(
                name: "CODE_UNI",
                table: "sys_pos",
                column: "code");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "sys_app");

            migrationBuilder.DropTable(
                name: "sys_code_generate");

            migrationBuilder.DropTable(
                name: "sys_code_generate_config");

            migrationBuilder.DropTable(
                name: "sys_config");

            migrationBuilder.DropTable(
                name: "sys_dict_data");

            migrationBuilder.DropTable(
                name: "sys_dict_type");

            migrationBuilder.DropTable(
                name: "sys_emp");

            migrationBuilder.DropTable(
                name: "sys_emp_ext_org_pos");

            migrationBuilder.DropTable(
                name: "sys_emp_pos");

            migrationBuilder.DropTable(
                name: "sys_file_info");

            migrationBuilder.DropTable(
                name: "sys_menu");

            migrationBuilder.DropTable(
                name: "sys_notice");

            migrationBuilder.DropTable(
                name: "sys_notice_user");

            migrationBuilder.DropTable(
                name: "sys_oauth_user");

            migrationBuilder.DropTable(
                name: "sys_op_log");

            migrationBuilder.DropTable(
                name: "sys_org");

            migrationBuilder.DropTable(
                name: "sys_pos");

            migrationBuilder.DropTable(
                name: "sys_role");

            migrationBuilder.DropTable(
                name: "sys_role_data_scope");

            migrationBuilder.DropTable(
                name: "sys_role_menu");

            migrationBuilder.DropTable(
                name: "sys_sms");

            migrationBuilder.DropTable(
                name: "sys_timers");

            migrationBuilder.DropTable(
                name: "sys_user");

            migrationBuilder.DropTable(
                name: "sys_user_data_scope");

            migrationBuilder.DropTable(
                name: "sys_user_role");

            migrationBuilder.DropTable(
                name: "sys_vis_log");
        }
    }
}
